; Disassembly of the file "z:\ramdisk\home\knoppix\CoBra Project\Software\ROM\EPROM Images - Saved from programmed EPROMs\EPROM_2K_COBRA_64K.BIN"
; 
; CPU Type: Z80
; 
; Created with dZ80 2.0
; 
; on Thursday, 04 of April 2013 at 07:27 PM
; 
; This code creates and uses a data block starting at F000:
; F000	9C	(set at line 0004)	CTC-0 INT. SVC. ADDR
; F001	06	(set at line 0004)	CTC-0 INT. SVC. ADDR
; F002					CTC-1 INT. SVC. ADDR
; F003					CTC-1 INT. SVC. ADDR
; F004					CTC-2 INT. SVC. ADDR
; F005					CTC-2 INT. SVC. ADDR
; F006					CTC-3 INT. SVC. ADDR
; F007					CTC-3 INT. SVC. ADDR
; F008	00	(set at line 0401)	storage start addr for bytes to be read from FDD (lower half)
; F009	80	(set at line 0401)	storage start addr for bytes to be read from FDD (upper half)
; F00A					CTC-2 time constant
; F00B					CTC-1 time constant	
; F00C	00	(set at line 03E4)	8272 command byte 1
; F00D	00	(set at line 03E4)	8272 command byte 2
; F00E	00	(set at line 03E4)	8272 command byte 3 (usually C, track no.)
; F00F	00	(set at line 03E4)	8272 command byte 4 (usually H, head no.)
; F010	01	(set at line 03E4)	8272 command byte 5 (usually R, current sector no.)
; F011	00	(set at line 03E4)	8272 command byte 6 (usually N, bytes per sector)
; F012	1A	(set at line 03E4)	8272 command byte 7 (usually EOT, last sector no. on cylinder, here 26)
; F013	06	(set at line 03E4)	8272 command byte 8 (usually GPL, Gap 3 length)
; F014	80	(set at line 03E4)	8272 command byte 9 (usually DTL, Data Length, user sector size if N=00, here 128)
; F015					result byte 1 from 8272 commands
; F016					result byte 2 from 8272 commands
; F017					result byte 3 from 8272 commands
; F018					result byte 4 from 8272 commands (C)
; F019					result byte 5 from 8272 commands (H)
; F01A					result byte 6 from 8272 commands (R)
; F01B					result byte 7 from 8272 commands (N)
; F01C					1A if FM or 28 if MFM (set in PARAM_SET)
; F01D					set to 00 in PARAM_SET
; F01E					current storage addr for next byte to be read from FDD after last 8272_CMD (lower half)
; F01F					current storage addr for next byte to be read from FDD after last 8272_CMD (upper half)
; F020					Read ID first result byte, ST0, AND-ed with C0h (00 = Read ID ok) see line 040A
; F021					00 if zero or formatted, 02 else (see line 042F)

0000           LD      A,$80
0002           LD      R,A	; set bit 7 of R to 1 to maintain startup config
0004           LD      HL,$069C	;										---@@@0006:06->0E
0007           LD      ($F000),HL	; (F000) <- 069C (CTC-0 Int. Vector for non-Result-Phase commands)
000A           LD      SP,$FFFF	; stack at FFFF
000D           LD      H,$C0
000F           LD      L,$00
0011           LD      (HL),$00	; (C000) <- 00 (video mem base)
0013           LD      D,H
0014           LD      E,$01	; DE <- C001
0016           LD      BC,$1AFF	; serial video mem size
0019           LDIR		; erase serial video mem (with 00)
001B           LD      A,$92
001D           OUT     ($DF),A	; write DF to 8255 Control Register
001F           LD      A,$40
0021           OUT     ($FE),A	; write 40 to 8255 Port C
				; ############### GRAPHIC LOGO ##################
0023           LD      BC,$78FE
0026           LD      H,$D9
0028           LD      L,$00	; HL = D900
002A           LD      B,$08	; BC = 08FE
002C           PUSH    BC	; BC on stack <--- <--- <--- <--- <--- <--- <--- <--- <--
002D           LD      BC,$0C05	; B = 0C as counter					|
0030           LD      (HL),C	; (D900) <- 05 (INK=5, PAPER=0)				|
0031           INC     HL	; do this for the first 12 bytes of the			|
0032           DJNZ    $0030	; color attr of middle third of screen			|
0034           LD      BC,$1403	; B = 14 as counter					|
0037           LD      (HL),C	; (D90C) <- 03 (INK=3, PAPER=0)				|
0038           INC     HL	; do this for the next 20 bytes of the			|
0039           DJNZ    $0037	; color attr of middle third of screen			|
003B           POP     BC	; BC = 08FE (B=08 used as counter)			|
003C           DJNZ    $002C	; repeat 8 times for all 8 rows of middle third ---> -->|
003E           EXX
003F           LD      HL,$0122	; HL' used as pointer to data block start address (0122)			---@@@0041:01->09
0042           EXX
0043           LD      H,$CB
0045           LD      L,$B9	; HL=CBB9, address within serial video RAM, middle third of screen
0047           LD      DE,$01FE	; data to be written in there
004A           LD      A,$04
004C           LD      B,$09
004E           PUSH    BC	; <--- <--- <--- <--- <--- <--- <--- <--- <--- <---
004F           LD      B,A	;						  |
0050           LD      (HL),D	; write "01" at CBB9 <--- <--- <- <--- 	<-	  |
0051           INC     HL	;				|	 |	  |
0052           LD      (HL),E	; write "FE" at CBBA		|	 |	  |
0053           EXX		;				|	 |	  |
0054           LD      A,(HL)	; read first byte of data (FF)	|	 |	  |
0055           INC     HL	; increment pointer (HL'=0189)	|	 |	  |
0056           EXX		;				|	 |	  |
0057           LD      C,A	; C = data byte			|	 |	  |
0058           ADD     A,L	; A = data byte + L = B9 + CY	|	 |	  |
0059           LD      L,A	; L = data byte + L		|	 |	  |
005A           JR      NC,$005D	;				|	 |	  |
005C           INC     H	; H=CB+1=CC			|	 |	  |
005D           DJNZ    $0050	; ---> ---> ---> ---> ---> --->>>	 |	  |
005F           LD      B,C	;					 |	  |
0060           EXX		;					 |	  |
0061           LD      E,(HL)	; Read 2 bytes				 |	  |
0062           INC     HL	; of data into				 |	  |
0063           LD      D,(HL)	; DE' register.				 |	  |
0064           INC     HL	; Increment pointer			 |	  |
0065           PUSH    DE	;					 |	  |
0066           EXX		;					 |	  |
0067           POP     HL	; HL = 2 data bytes			 |	  |
0068           SLA     E	;					 |	  |
006A           RL      D	;					 |	  |
006C           JR      NC,$0050	; ---> ---> ---> ---> ---> ---> ---> --->>	  |
006E           RR      D	;						  |
0070           RR      E	;						  |
0072           LD      D,$FF	;						  |
0074           SLA     D	; <----						  |
0076           RL      E	;     |						  |
0078           JR      C,$0074	; ---->						  |
007A           LD      A,D	;						  |
007B           CPL		;						  |
007C           LD      D,A	;						  |
007D           LD      E,$FF	;						  |
007F           LD      A,C	;						  |
0080           POP     BC	;						  |
0081           DJNZ    $004E	; ---> ---> ---> ---> ---> ---> ---> ---> ---> --->
0083           LD      E,L
0084           LD      D,H
0085           EXX
0086           PUSH    HL
0087           EXX
0088           POP     HL
0089           LD      B,$0B
008B           PUSH    BC	; <--- <---
008C           LD      B,A	;	  |
008D           LD      A,(HL)	;	  |
008E           INC     HL	;	  |
008F           LD      (DE),A	; <----   |
0090           INC     DE	;     |   |
0091           DJNZ    $008F	; ---->   |
0093           LD      A,(HL)	;	  |
0094           INC     HL	;	  |
0095           LD      E,(HL)	;	  |
0096           INC     HL	;	  |
0097           LD      D,(HL)	;	  |
0098           INC     HL	;	  |
0099           POP     BC	;	  |
009A           DJNZ    $008B	; ---> --->
009C           LD      BC,$0008	; length of color pattern under logo
009F           LD      DE,$DA8C	; addr of color attr for color pattern under logo (within video mem)
00A2           LD      HL,$037A	; addr of color attr for color pattern under logo (within data block)		---@@@00A4:03->0B
00A5           LDIR
00A7           LD      D,$07	; ######### BEGINNING OF ONE SCREEN CYCLE (KBD READ + SCROLL LEFT) #########
00A9           LD      BC,$0000
00AC           PUSH    BC	; <--- <--- <--- <--- <--- <--- <--- <--- <--- <--- <--- <--- <-|
00AD           LD      BC,$78FE	; B=78 for keyboard test, rows KA15, KA10, KA9, KA8, C=FE for port addr
00B0           IN      A,(C)	;								|
00B2           NOP		;								|
00B3           NOP		;								|
00B4           JP      $0705	; jump to keyboard read						|		---@@@00B6:07->0F
00B7           RRA		; return point from 0705, test column K2 ("M" "E" "D" "X")	|
00B8           JP      NC,$03D8	; if any key pressed jump to DISK LOADING			|		---@@@00BA:03->0B
00BB           RRA     		; test column K3 ("N" "R" "F" "C")				|
00BC           JP      NC,$06DF	; if any key pressed jump to TAPE LOADING (?)			|		---@@@00BE:06->0E
00BF           RRA     		; test column K4 ("B" "T" "G" "V")				|
00C0           JP      NC,$0719	; if any key pressed jump to TAPE VERIFY (?)			|		---@@@00C2:07->0F
00C3           RRA		;								|
00C4           POP     BC	;								|
00C5           DJNZ    $00AC	; ---> ---> ---> x256 ---> ---> ---> ---> ---> ---> ---> ---> ->|
00C7           DEC     C	; C=FF								|
00C8           JR      NZ,$00AC	; ---> ---> ---> x256 ---> ---> ---> ---> ---> ---> ---> ---> ->|
00CA           DEC     D	;								|
00CB           JR      NZ,$00AC	; ---> ---> ---> x7   ---> ---> ---> ---> ---> ---> ---> ---> ->|
00CD           LD      B,$20
00CF           PUSH    BC	; BC=2000
00D0           CALL    $00F1	; call SERIAL VIDEO GRAPHIC SCROLL LEFT 4 PIXELS				---@@@00D2:00->08
00D3           LD      H,$D9
00D5           LD      L,$01	; HL=D901 ######## 00D5-00E7 mid screen attribute scroll left 1 char ########
00D7           LD      B,$08
00D9           PUSH    BC	; BC=0800 (B=08 used as row counter)    <--- <--- <--- <--- <---|
00DA           LD      BC,$001F	; screen width in chars minus 1					|
00DD           LD      D,H	;								|
00DE           LD      E,L	; DE=D901							|
00DF           DEC     E	; DE=D900 (start of row 1 (of 8) of attr's for middle third of screen)
00E0           LD      A,(DE)	; copy the first attr byte on the row				|
00E1           LDIR		; shift 31 attribute bytes left, first byte overwritten		|
00E3           LD      (DE),A	; save the former first byte into the last on the row		|
00E4           INC     L	; HL now points to first char on next row			|
00E5           INC     E	; DE now points to last char on row				|
00E6           POP     BC	; POP back the row counter					|
00E7           DJNZ    $00D9	; ---> ---> ---> ---> ---> ---> ---> ---> ---> ---> ---> ---> ->|    ########
00E9           CALL    $00F1	; call SERIAL VIDEO GRAPHIC SCROLL LEFT 4 PIXELS				---@@@00EB:00->08
00EC           POP     BC
00ED           DJNZ    $00CF
00EF           JR      $00A7	; ######### END OF ONE SCREEN CYCLE (KBD READ + SCROLL LEFT) #########

00F1           LD      B,$04	; ######### SERIAL VIDEO GRAPHIC SCROLL LEFT 4 PIXELS ##########
00F3           PUSH    BC	; <--- <--- <--- <--- <--- <--- <--- <--- <--- <--- <--- <--- <--- <----|
00F4           LD      H,$CF	;									|
00F6           LD      L,$FF	; HL=CFFF (end address of middle third of screen serial video mem)	|
00F8           LD      B,$08	;									|
00FA           PUSH    BC	; char line counter <--- <--- <--- <--- <--- <--- <--- <--- <-----|	|
00FB           LD      B,$08	;								  |	|
00FD           PUSH    BC	; pixel row counter on a char line <--- <--- <--- <-----|	  |	|
00FE           LD      D,H	;							|	  |	|
00FF           LD      E,L	; DE=CFFF (store the end address of crt pixel row)	|	  |	|
0100           LD      B,$20	; char counter for one screen row			|	  |	|
0102           SCF		; CY=1 (last pixel on row will show as INK)		|	  |	|
0103           RL      (HL)	; rotate left through CY <--- <--- <--- <--- <--|	|	  |	|
0105           DEC     HL	; HL=address counter				|	|	  |	|
0106           DJNZ    $0103	; shift all bytes on a row 1 bit left ---> ---->|	|	  |	|
0108           JR      C,$010D	; if first bit on row was 1, skip 3 lines		|	  |	|
010A           LD      A,(DE)	;	(the last byte on crt pixel row)		|	  |	|
010B           DEC     A	; 	-1 (when first bit on row was 0)		|	  |	|
010C           LD      (DE),A	;	save corrected value				|	  |	|
010D           POP     BC	; pixel row counter on a char line			|	  |	|
010E           SCF		;							|	  |	|
010F           CCF		; CY=0							|	  |	|
0110           LD      DE,$00E0	; 7 rows x 32 chars to get to end of prev. pixel row on same char line	|
0113           SBC     HL,DE	; HL=HL-DE-CY (end of prev pixel row on same char line) |	  |	|
0115           DJNZ    $00FD	; ---> ---> ---> ---> ---> ---> ---> ---> ---> ---> --->|	  |	|
				; after 1 char row is fully shifted, HL points to last byte	  |	|
				; on the first pixel row of the previous char row, minus E0.	  |	|
				; we need to get to last byte on last pixel row of prev char row. |	|
0117           LD      BC,$07E0	; 20h x 8 x 7 + E0h (E0 is correction to last subtraction)	  |	|
011A           ADD     HL,BC	; HL now points to last byte on last pixel row of prev char row   |	|
011B           POP     BC	; char line counter						  |	|
011C           DJNZ    $00FA	; ---> ---> ---> ---> ---> ---> ---> ---> ---> ---> ---> ---> --->|	|
011E           POP     BC	; pixel displacement counter						|
011F           DJNZ    $00F3	; ---> ---> ---> ---> ---> ---> ---> ---> ---> ---> ---> ---> ---> ---->|
0121           RET
				; ############ GRAPHIC DATA BLOCK ###########
0122           DB      $FF
0123           DB      $E0
0124           DB      $FF
0125           DB      $1F
0126           DB      $B1
0127           DB      $C8
0128           DB      $45
0129           DB      $B9
012A           DB      $22
012B           DB      $02
012C           DB      $1F
012D           DB      $A2
012E           DB      $16
012F           DB      $22
0130           DB      $02
0131           DB      $1F
0132           DB      $A2
0133           DB      $16
0134           DB      $25
0135           DB      $15
0136           DB      $09
0137           DB      $75
0138           DB      $43
0139           DB      $25
013A           DB      $BC
013B           DB      $02
013C           DB      $19
013D           DB      $25
013E           DB      $BC
013F           DB      $02
0140           DB      $19
0141           DB      $07
0142           DB      $1D
0143           DB      $D9
0144           DB      $07
0145           DB      $1D
0146           DB      $0C
0147           DB      $9A
0148           DB      $C8
0149           DB      $07
014A           DB      $A5
014B           DB      $90
014C           DB      $FF
014D           DB      $88
014E           DB      $FF
014F           DB      $E5
0150           DB      $FF
0151           DB      $FF
0152           DB      $31
0153           DB      $07
0154           DB      $0C
0155           DB      $82
0156           DB      $C8
0157           DB      $FF
0158           DB      $FF
0159           DB      $FF
015A           DB      $6D
015B           DB      $7F
015C           DB      $09
015D           DB      $07
015E           DB      $F7
015F           DB      $07
0160           DB      $DF
0161           DB      $FF
0162           DB      $09
0163           DB      $CC
0164           DB      $C8
0165           DB      $7B
0166           DB      $92
0167           DB      $FF
0168           DB      $FF
0169           DB      $EB
016A           DB      $FF
016B           DB      $FF
016C           DB      $C4
016D           DB      $10
016E           DB      $AF
016F           DB      $C8
0170           DB      $FC
0171           DB      $02
0172           DB      $FC
0173           DB      $02
0174           DB      $FC
0175           DB      $02
0176           DB      $FC
0177           DB      $02
0178           DB      $FC
0179           DB      $02
017A           DB      $FC
017B           DB      $02
017C           DB      $0B
017D           DB      $F3
017E           DB      $0B
017F           DB      $06
0180           DB      $87
0181           DB      $C8
0182           DB      $C0
0183           DB      $FF
0184           DB      $FF
0185           DB      $72
0186           DB      $FF
0187           DB      $0B
0188           DB      $46
0189           DB      $C8
018A           DB      $74
018B           DB      $6E
018C           DB      $3D
018D           DB      $52
018E           DB      $8E
018F           DB      $9F
0190           DB      $FE
0191           DB      $DD
0192           DB      $FF
0193           DB      $82
0194           DB      $11
0195           DB      $8C
0196           DB      $C8
0197           DB      $62
0198           DB      $55
0199           DB      $20
019A           DB      $E1
019B           DB      $70
019C           DB      $8E
019D           DB      $DA
019E           DB      $A3
019F           DB      $7A
01A0           DB      $5F
01A1           DB      $9F
01A2           DB      $5F
01A3           DB      $CC
01A4           DB      $2A
01A5           DB      $28
01A6           DB      $08
01A7           DB      $0B
01A8           DB      $62
01A9           DB      $C8
01AA           DB      $E5
01AB           DB      $FF
01AC           DB      $FF
01AD           DB      $59
01AE           DB      $F7
01AF           DB      $07
01B0           DB      $A5
01B1           DB      $70
01B2           DB      $B6
01B3           DB      $D1
01B4           DB      $13
01B5           DB      $D1
01B6           DB      $C8
01B7           DB      $02
01B8           DB      $02
01B9           DB      $01
01BA           DB      $88
01BB           DB      $37
01BC           DB      $07
01BD           DB      $2E
01BE           DB      $90
01BF           DB      $3F
01C0           DB      $A5
01C1           DB      $8B
01C2           DB      $BF
01C3           DB      $02
01C4           DB      $F9
01C5           DB      $FF
01C6           DB      $FF
01C7           DB      $02
01C8           DB      $02
01C9           DB      $08
01CA           DB      $D1
01CB           DB      $CA
01CC           DB      $76
01CD           DB      $90
01CE           DB      $ED
01CF           DB      $9A
01D0           DB      $2E
01D1           DB      $E8
01D2           DB      $07
01D3           DB      $09
01D4           DB      $CC
01D5           DB      $C9
01D6           DB      $7B
01D7           DB      $86
01D8           DB      $78
01D9           DB      $92
01DA           DB      $EB
01DB           DB      $9F
01DC           DB      $27
01DD           DB      $FC
01DE           DB      $0B
01DF           DB      $AC
01E0           DB      $C8
01E1           DB      $22
01E2           DB      $0B
01E3           DB      $F3
01E4           DB      $FC
01E5           DB      $FF
01E6           DB      $FA
01E7           DB      $FF
01E8           DB      $C7
01E9           DB      $FF
01EA           DB      $1C
01EB           DB      $03
01EC           DB      $BB
01ED           DB      $CD
01EE           DB      $B4
01EF           DB      $F6
01F0           DB      $10
01F1           DB      $2A
01F2           DB      $C8
01F3           DB      $C6
01F4           DB      $54
01F5           DB      $03
01F6           DB      $FD
01F7           DB      $72
01F8           DB      $38
01F9           DB      $F5
01FA           DB      $DC
01FB           DB      $7B
01FC           DB      $30
01FD           DB      $02
01FE           DB      $F8
01FF           DB      $32
0200           DB      $A6
0201           DB      $26
0202           DB      $0C
0203           DB      $66
0204           DB      $C8
0205           DB      $28
0206           DB      $FC
0207           DB      $BB
0208           DB      $FF
0209           DB      $DE
020A           DB      $FB
020B           DB      $E4
020C           DB      $BA
020D           DB      $08
020E           DB      $FA
020F           DB      $07
0210           DB      $01
0211           DB      $46
0212           DB      $CF
0213           DB      $01
0214           DB      $46
0215           DB      $CE
0216           DB      $05
0217           DB      $CC
0218           DB      $CA
0219           DB      $FF
021A           DB      $FA
021B           DB      $7E
021C           DB      $45
021D           DB      $01
021E           DB      $46
021F           DB      $CC
0220           DB      $01
0221           DB      $46
0222           DB      $CB
0223           DB      $0C
0224           DB      $91
0225           DB      $C8
0226           DB      $B6
0227           DB      $FD
0228           DB      $E1
0229           DB      $9B
022A           DB      $7E
022B           DB      $85
022C           DB      $FD
022D           DB      $FF
022E           DB      $61
022F           DB      $79
0230           DB      $2D
0231           DB      $0A
0232           DB      $24
0233           DB      $C9
0234           DB      $6A
0235           DB      $FC
0236           DB      $57
0237           DB      $EC
0238           DB      $F5
0239           DB      $FB
023A           DB      $08
023B           DB      $56
023C           DB      $AB
023D           DB      $02
023E           DB      $CC
023F           DB      $CB
0240           DB      $BF
0241           DB      $04
0242           DB      $ED
0243           DB      $CA
0244           DB      $E1
0245           DB      $BF
0246           DB      $DD
0247           DB      $03
0248           DB      $D1
0249           DB      $CB
024A           DB      $95
024B           DB      $29
024C           DB      $01
024D           DB      $E6
024E           DB      $C8
024F           DB      $0D
0250           DB      $C3
0251           DB      $C8
0252           DB      $CD
0253           DB      $62
0254           DB      $F3
0255           DB      $5A
0256           DB      $E3
0257           DB      $FF
0258           DB      $A1
0259           DB      $40
025A           DB      $1E
025B           DB      $4A
025C           DB      $02
025D           DB      $59
025E           DB      $0D
025F           DB      $8F
0260           DB      $CA
0261           DB      $FC
0262           DB      $02
0263           DB      $97
0264           DB      $9B
0265           DB      $08
0266           DB      $02
0267           DB      $09
0268           DB      $F5
0269           DB      $09
026A           DB      $2A
026B           DB      $62
026C           DB      $BB
026D           DB      $01
026E           DB      $E6
026F           DB      $C8
0270           DB      $04
0271           DB      $F0
0272           DB      $CA
0273           DB      $F8
0274           DB      $DD
0275           DB      $A8
0276           DB      $02
0277           DB      $C3
0278           DB      $C9
0279           DB      $7F
027A           DB      $14
027B           DB      $94
027C           DB      $C8
027D           DB      $02
027E           DB      $5C
027F           DB      $FB
0280           DB      $A0
0281           DB      $FF
0282           DB      $22
0283           DB      $02
0284           DB      $52
0285           DB      $A9
0286           DB      $02
0287           DB      $19
0288           DB      $09
0289           DB      $4D
028A           DB      $A7
028B           DB      $09
028C           DB      $ED
028D           DB      $AA
028E           DB      $02
028F           DB      $5C
0290           DB      $0C
0291           DB      $43
0292           DB      $C8
0293           DB      $B5
0294           DB      $EA
0295           DB      $3F
0296           DB      $E3
0297           DB      $BA
0298           DB      $40
0299           DB      $C2
029A           DB      $FF
029B           DB      $FF
029C           DB      $11
029D           DB      $FF
029E           DB      $07
029F           DB      $43
02A0           DB      $C9
02A1           DB      $E4
02A2           DB      $9A
02A3           DB      $84
02A4           DB      $AA
02A5           DB      $7F
02A6           DB      $02
02A7           DB      $07
02A8           DB      $ED
02A9           DB      $C9
02AA           DB      $FA
02AB           DB      $7E
02AC           DB      $BF
02AD           DB      $FF
02AE           DB      $FF
02AF           DB      $45
02B0           DB      $17
02B1           DB      $26
02B2           DB      $C8
02B3           DB      $D4
02B4           DB      $98
02B5           DB      $02
02B6           DB      $1C
02B7           DB      $02
02B8           DB      $DC
02B9           DB      $02
02BA           DB      $1C
02BB           DB      $02
02BC           DB      $52
02BD           DB      $FD
02BE           DB      $20
02BF           DB      $FD
02C0           DB      $8C
02C1           DB      $02
02C2           DB      $1C
02C3           DB      $DF
02C4           DB      $02
02C5           DB      $1C
02C6           DB      $06
02C7           DB      $ED
02C8           DB      $11
02C9           DB      $2A
02CA           DB      $28
02CB           DB      $C8
02CC           DB      $6A
02CD           DB      $02
02CE           DB      $1C
02CF           DB      $02
02D0           DB      $3C
02D1           DB      $9F
02D2           DB      $02
02D3           DB      $1C
02D4           DB      $02
02D5           DB      $3C
02D6           DB      $05
02D7           DB      $99
02D8           DB      $02
02D9           DB      $1C
02DA           DB      $02
02DB           DB      $3C
02DC           DB      $05
02DD           DB      $0A
02DE           DB      $8E
02DF           DB      $02
02E0           DB      $1C
02E1           DB      $02
02E2           DB      $42
02E3           DB      $B9
02E4           DB      $02
02E5           DB      $1C
02E6           DB      $9F
02E7           DB      $02
02E8           DB      $3C
02E9           DB      $02
02EA           DB      $1C
02EB           DB      $9F
02EC           DB      $02
02ED           DB      $3C
02EE           DB      $02
02EF           DB      $1C
02F0           DB      $9F
02F1           DB      $02
02F2           DB      $3C
02F3           DB      $02
02F4           DB      $1C
02F5           DB      $01
02F6           DB      $E6
02F7           DB      $C8
02F8           DB      $17
02F9           DB      $8D
02FA           DB      $C8
02FB           DB      $26
02FC           DB      $02
02FD           DB      $31
02FE           DB      $03
02FF           DB      $38
0300           DB      $66
0301           DB      $6D
0302           DB      $91
0303           DB      $6D
0304           DB      $2D
0305           DB      $63
0306           DB      $06
0307           DB      $02
0308           DB      $63
0309           DB      $D1
030A           DB      $06
030B           DB      $F8
030C           DB      $FF
030D           DB      $9F
030E           DB      $46
030F           DB      $02
0310           DB      $15
0311           DB      $06
0312           DB      $25
0313           DB      $C8
0314           DB      $BE
0315           DB      $43
0316           DB      $FF
0317           DB      $FB
0318           DB      $C0
0319           DB      $08
031A           DB      $E9
031B           DB      $C9
031C           DB      $3C
031D           DB      $02
031E           DB      $3D
031F           DB      $E1
0320           DB      $DD
0321           DB      $9D
0322           DB      $83
0323           DB      $29
0324           DB      $E6
0325           DB      $C8
0326           DB      $01
0327           DB      $5F
0328           DB      $9D
0329           DB      $01
032A           DB      $07
032B           DB      $37
032C           DB      $1F
032D           DB      $9D
032E           DB      $01
032F           DB      $1D
0330           DB      $01
0331           DB      $1D
0332           DB      $01
0333           DB      $1F
0334           DB      $9E
0335           DB      $01
0336           DB      $1C
0337           DB      $01
0338           DB      $1C
0339           DB      $01
033A           DB      $9D
033B           DB      $01
033C           DB      $5D
033D           DB      $01
033E           DB      $20
033F           DB      $7C
0340           DB      $01
0341           DB      $3E
0342           DB      $01
0343           DB      $1C
0344           DB      $01
0345           DB      $20
0346           DB      $27
0347           DB      $54
0348           DB      $01
0349           DB      $5D
034A           DB      $01
034B           DB      $20
034C           DB      $7C
034D           DB      $01
034E           DB      $01
034F           DB      $45
0350           DB      $C8
0351           DB      $C3
0352           DB      $01
0353           DB      $87
0354           DB      $C8
0355           DB      $03
0356           DB      $01
0357           DB      $87
0358           DB      $C9
0359           DB      $01
035A           DB      $01
035B           DB      $68
035C           DB      $CE
035D           DB      $E0
035E           DB      $01
035F           DB      $67
0360           DB      $CF
0361           DB      $07
0362           DB      $0A
0363           DB      $03
0364           DB      $D9
0365           DB      $01
0366           DB      $02
0367           DB      $27
0368           DB      $D9
0369           DB      $35
036A           DB      $01
036B           DB      $47
036C           DB      $D9
036D           DB      $15
036E           DB      $04
036F           DB      $48
0370           DB      $D9
0371           DB      $02
0372           DB      $01
0373           DB      $8B
0374           DB      $D9
0375           DB      $03
0376           DB      $01
0377           DB      $AB
0378           DB      $D9
0379           DB      $03
037A           DB      $07
037B           DB      $0E
037C           DB      $15
037D           DB      $1C
037E           DB      $23
037F           DB      $2A
0380           DB      $31
0381           DB      $38
				; ####### DISK PARAMS BLOCK #######
0382           DB      $00
0383           DB      $00
0384           DB      $00
0385           DB      $00
0386           DB      $01
0387           DB      $00
0388           DB      $1A
0389           DB      $06
038A           DB      $80
				; ####### FM SECTOR TABLE #######
				; --- 8" floppy, 26 sectors, interleave 6 ---
038B           DB      $01	; 1
038C           DB      $07	; 7
038D           DB      $0D	; 13
038E           DB      $13	; 19
038F           DB      $19	; 25
0390           DB      $05	; 5
0391           DB      $0B	; 11
0392           DB      $11	; 17
0393           DB      $17	; 23
0394           DB      $03	; 3
0395           DB      $09	; 9
0396           DB      $0F	; 15
0397           DB      $15	; 21
0398           DB      $02	; 2
0399           DB      $08	; 8
039A           DB      $0E	; 14
039B           DB      $14	; 20
039C           DB      $1A	; 26
039D           DB      $06	; 6
039E           DB      $0C	; 12
039F           DB      $12	; 18
03A0           DB      $18	; 24
03A1           DB      $04	; 4
03A2           DB      $0A	; 10
03A3           DB      $10	; 16
03A4           DB      $16	; 22
				; ###### MFM SECTOR TABLE
				; --- 10 sectors, interleave 3 ---
03A5           DB      $01	; 1
03A6           DB      $04	; 4
03A7           DB      $07	; 7
03A8           DB      $0A	; 10
03A9           DB      $03	; 3
03AA           DB      $06	; 6
03AB           DB      $09	; 9
03AC           DB      $02	; 2
03AD           DB      $05	; 5
03AE           DB      $08	; 8
				; ###### CP/M loader dir entry
03AF           DB      $00	; user no.
03B0           DB      $53	; "S"
03B1           DB      $59	; "Y"
03B2           DB      $53	; "S"
03B3           DB      $20	; " "
03B4           DB      $20	; " "
03B5           DB      $20	; " "
03B6           DB      $20	; " "
03B7           DB      $20	; " "
03B8           DB      $43	; "C"
03B9           DB      $4F	; "O"
03BA           DB      $4D	; "M"

03BB           LD      IX,$0000	; ########## ???????????????? ##########
03BF           LD      DE,$2000
03C2           LD      A,$FE
03C4           SCF
03C5           CALL    $04C2	; strange call !! EX AF,AF';INC B + rest of READ_DISK				---@@@03C7:04->0C
03C8           LD      IX,$2000
03CC           LD      DE,$2000
03CF           LD      A,$FE
03D1           SCF
03D2           CALL    $04C2	;										---@@@03D4:04->0C
03D5           JP      $0000	;										---@@@03D7:00->08
				; ############ DISK LOADING ############
03D8           CALL    $05FE	; call FDD_SPECIFY								---@@@03DA:05->0D
03DB           LD      BC,$0009	;
03DE           LD      HL,$0382	; copy to RAM									---@@@03E0:03->0B
03E1           LD      DE,$F00C	; 9 bytes from 0382 to F00C
03E4           LDIR		; (8272 command opcode storage area)
03E6           CALL    $05E9	; call SENSE DRIVE STATUS (drive number in (F00D)) <----|			---@@@03E8:05->0D
03E9           AND     $20	; test bit 5 of status info (READY)			|
03EB           JR      NZ,$03FB	; if READY skip fwd ---> ---> -->|			|
03ED           LD      A,($F00D); A=00				 |			|
03F0           INC     A	; increment the drive number	 |			|
03F1           LD      ($F00D),A; (F00D)=01			 |			|
03F4           CP      $04	; check all 4 drives		 |			|
03F6           JR      NZ,$03E6	; ---> ---> ---> ---> ---> ---> ---> ---> ---> ---> --->|
03F8           JP      $0000	; if no drive ready restart BOOT |						---@@@03FA:00->08
03FB           CALL    $05A8	; call RECALIBRATE <--- <--- <---| *** at this point CTC-0_INT_1		---@@@03FD:05->0D
03FE           LD      HL,$8000
0401           LD      ($F008),HL ; storage addr for bytes read from 8272 by 8272_CMD
0404           LD      BC,$0A01	; (B=first opcode of 8272 cmd, Read ID in FM mode, C=nr.opcodes-1)
0407           CALL    $04B3	; call 8272_CMD_PARM (run Read ID) *** during 8272_CMD -> CTC-0_INT_2		---@@@0409:04->0C
				;				   *** after this point-> CTC-0_INT_1
040A           LD      ($F020),A; Read ID first result byte, ST0, AND-ed with C0h (00 = Read ID ok)
040D           XOR     A
040E           LD      ($F00E),A; (F00E)=00 (track no.)
0411           INC     A
0412           LD      ($F010),A; (F010)=01 (sector no.)
0415           CALL    $0563	; call PARAM_SET (prepare for Read Data)					---@@@0417:05->0D
0418           LD      C,$08	; nr of 8272 command opcodes minus 1 *** at this point -> CTC-0_INT_1
041A           CALL    $04EE	; call SEEK+CMD (Read Data)	   *** after SEEK -> CTC-0_INT_2		---@@@041C:04->0C
041D           JP      NZ,$0000	; if non-zero Read Data first result byte (error), restart BOOT			---@@@041F:00->08
0420           LD      A,($8000); first byte read from disk
0423           OR      A
0424           JR      Z,$042E	; if zero skip 4 lines ---> --->|
0426           CP      $E5	; check if default value after formatting
0428           JR      Z,$042E	; if so skip 2 lines ---> ----->|
042A           LD      A,$02	;				|
042C           JR      $042F	; --> -->|			|
042E           XOR     A	; <--- <--- <--- <--- <--- <----|
042F           LD      ($F021),A; <-- <--| (F021)=00 if zero or formatted, 02 else
0432           CALL    $0563	; call PARAM_SET								---@@@0434:05->0D
0435           CALL    $04BE	; call READ_DISK								---@@@0437:04->0C
0438           CALL    $0509	; call DIR_SEARCH								---@@@043A:05->0D
043B           JP      C,$0000	;										---@@@043D:00->08
043E           LD      DE,$8800
0441           LD      ($F008),DE ; store data bytes from 8272 at (8800)
0445           LD      DE,$0010
0448           ADD     HL,DE	; addr of dir entry found in data stored at 8000, plus 10h (1-byte block addresses)
0449           LD      A,(HL)	; addr of first block on disk for this file
044A           OR      A	; CY flag is reset
044B           JR      Z,$0490	; ---> ---> ---> ---> ---> ---> ---> ---> ---> ---> --->|
044D           PUSH    HL
044E           LD      H,$00
0450           LD      L,A	; addr of first block on disk for this file as a 16-bit value
0451           CALL    $0530	;							|			---@@@0453:05->0D
0454           LD      A,($F011) ; bytes per sector, N
0457           OR      A
0458           JR      Z,$045F	; ---> ---> ---> ---> ---> --->|
045A           LD      BC,$0208	;			       | BC=0208 if N not zero
045D           JR      $0462	; ---> ---> ---> ---> ---> --->|---> ---> ----->|
045F           LD      BC,$0808	; <--- <--- <--- <--- <--- <---| BC=0808 if N=0 |
0462           LD      A,D	; <--- <--- <--- <--- <--- <--- <--- <--- <-----|
0463           LD      ($F00E),A ; track number
0466           PUSH    DE
0467           LD      D,00
0469           CALL    $0559	; READ_TABLE					|	|			---@@@046B:05->0D
046C           LD      ($F010),A ; sector number
046F           CALL    $04EE	; SEEK+CMD					|	|			---@@@0471:04->0C
0472           JP      NZ,$0000	;						|	|			---@@@0474:00->08
0475           LD      HL,($F01E)
0478           LD      ($F008),HL
047B           LD      HL,($F01C)
047E           INC     HL
047F           POP     DE
0480           INC     E
0481           LD      A,E
0482           CP      L
0483           JP      C,$0489	;						|	|			---@@@0485:04->0C
0486           INC     D
0487           LD      A,$01
0489           LD      E,A
048A           DJNZ    $0462	; ---> ---> ---> ---> ---> ---> ---> ---> ----->|
048C           POP     HL
048D           INC     HL
048E           JR      $0449
0490           LD      HL,$04A5	; <--- <--- <--- <--- <--- <--- <--- <--- <--- <--- <---|			---@@@0492:04->0C
0493           LD      DE,$E000
0496           LD      BC,$000E
0499           LDIR
049B           LD      HL,$E000
049E           LD      A,$40
04A0           OUT     ($FE),A	; set "O6" to 1 (for CP/M config)
04A2           LD      R,A	; reset bit 7 of R (change to CP/M config)
04A4           JP      (HL)
04A5           LD      HL,$8800	; this code is relocated
04A8           LD      DE,$0100	; at E000 and executed
04AB           LD      BC,$5000	; from there by the
04AE           LDIR		; instructions above
04B0           JP      $0100	; (lines 0490 to 04A4)
				;
				; ######### 8272_CMD_PARM ###########
				; --- input: B = first 8272 opcode
04B3           LD      A,B	; A=0A (see line 404)
04B4           LD      ($F00C),A; (F00C)=0A (first byte of 8272 command - Read ID in FM mode)
04B7           LD      HL,$06BA	; CTC-0_INT_2 (for Result-Phase commands)					---@@@04B9:06->0E
04BA           CALL    $0647	; call 8272_CMD									---@@@04BC:06->0E
04BD           RET
				; ######### READ_DISK ###############
				; ---input: A = 00 if FM, 02 if MFM
04BE           OR      A
04BF           JR      Z,$04C6	; --->| 00 if FM, 02 if MFM
04C1           LD      BC,$0408	;     |      BC=0408 if MFM (B=nr.of loops, C=nr.of 8272 opcodes-1)
04C4           JR      $04C9	; --->|--->|
04C6           LD      BC,$1008	; <---|    | BC=1008 if FM (B=nr.of loops, C=nr.of 8272 opcodes-1)
04C9           LD      A,($F021); <--- <---|
04CC           LD      ($F00E),A; track no. in (F00E) for SEEK+CMD
04CF           LD      A,$01	; initial displacement to read from in table for READ_TABLE
04D1           PUSH    AF	; <--- <--- <--- <--- <--- <--- <--- <--- <--- <--- <---|
04D2           LD      E,A	;							|
04D3           LD      D,$00	;							|
04D5           CALL    $0559	; call READ_TABLE, read from displacement in A		|			---@@@04D7:05->0D
04D8           LD      ($F010),A; store in (F010) - sector number			|
04DB           CALL    $04EE	; call SEEK+CMD (Read Data, (F00C) set at line 0415)	|			---@@@04DD:04->0C
04DE           JR      NZ,$04EB	; restart BOOT if Read Data finished w err		|
04E0           LD      HL,($F01E) ; storage addr for next read from disk (see 8272_CMD)	|
04E3           LD      ($F008),HL ; (F008+F009) = dest addr for next data from FDD	|
04E6           POP     AF	;							|
04E7           INC     A	;							|
04E8           DJNZ    $04D1	; 4 loops if MFM, 16 if FM ---> ---> ---> ---> ---> --->|
04EA           RET

04EB           JP      $0000	;										---@@@04ED:00->08
				; ######### SEEK+CMD #########
				; *** SEEK on specified drive to specified track and then run an 8272 command
				; --- input: C = nr. of 8272 opcodes - 1
				; --- input: (F00C) = first 8272 opcode for 8272_CMD
				; --- input: (F00D) = drive number to SEEK
				; --- input: (F00E) = track number to SEEK
				; --- output: A=0 if ok, A nonzero if err
				; --- output: Z flag set if ok, reset if err
04EE           PUSH    BC
04EF           CALL    $05B9	; call SEEK, (F00D)=drive number, (F00E)=track number				---@@@04F1:05->0D
04F2           POP     BC
04F3           LD      E,$0A
04F5           PUSH    BC	; <--- <--- <--- <--- <--|
04F6           PUSH    DE	;			 |
04F7           LD      HL,$06BA	; CTC-0_INT_2		 | (for Result-Phase commands)				---@@@04F9:06->0E
04FA           CALL    $0647	; call 8272_CMD		 |							---@@@04FC:06->0E
04FD           POP     DE	;			 |
04FE           POP     BC	;			 |
04FF           RET     Z	; return if 8272_CMD err |
0500           DEC     E	;			 |
0501           JR      NZ,$04F5	; --> ---> ---> ---> --->|
0503           LD      A,($F015); 8272_CMD first result data byte, ST0
0506           AND     $C0	; test bits 6, 7 (Command Termination code)
0508           RET
				; ############### DIR_SEARCH ###################
				; *** search for dir entry stored at 03AF in the directory read from disk at 8000
				; --- output: Z flag set if dir entry found
				; --- output: HL = addr of dir entry found in data stored at 8000
0509           LD      HL,$8000	; address of bytes read from FDD
050C           LD      DE,$03AF	;										---@@@050E:03->0B
050F           LD      B,$40	; search 64 consecutive directory entries
0511           CALL    $051F	; call STR_COMP  <--- <--- <--- <--- <--- <--- <--- <--- <---|			---@@@0513:05->0D
0514           RET     Z	; return if strings equal				     |
				;							     |
0515           PUSH    DE
0516           LD      DE,$0020
0519           ADD     HL,DE	; increment HL by 20h (32), length of one dir entry
051A           POP     DE
051B           DJNZ    $0511	; ---> ---> ---> ---> ---> ---> ---> ---> ---> ---> ---> --->|
051D           SCF
051E           RET
				; ############### STR_COMP #####################
				; *** compare 12 bytes from (DE) with 12 bytes from (HL)
051F           PUSH    HL
0520           PUSH    DE
0521           PUSH    BC
0522           LD      B,$0C
0524           LD      A,(DE)	; <--- <--- <--- <--- <---|
0525           CP      (HL)	; compare (DE) with (HL)  |
0526           JR      NZ,$052C	; exit loop if different  |
0528           INC     HL	; 			  |
0529           INC     DE	;			  |
052A           DJNZ    $0524	; ---> ---> ---> ---> --->|
052C           POP     BC
052D           POP     DE
052E           POP     HL
052F           RET		; returns Z if strings equal, NZ if different
				; #############
0530           LD      BC,$03FF	; B=03 for 3 loops, C=FF for counting from 0 up
0533           SLA     L	; <--- <--- <--- <--- <-|
0535           RL      H	; HL = HL * 2		|
0537           DJNZ    $0533	; HL = HL * 8 ---> ---->|
0539           INC     HL	; HL = HL + 1  >>> HL=HL*8+1
053A           LD      DE,($F01C) ; 1A if FM or 28 if MFM (set in PARAM_SET)
053E           INC     C	; C = C + 1 <--- <--- <--- <--- <--- <---|
053F           SBC     HL,DE	; HL = HL-(1A if FM or 28 if MFM)-CY	 |
0541           JR      NC,$053E	; ---> ---> ---> ---> ---> ---> ---> --->|
0543           ADD     HL,DE
0544           LD      A,($F011) ; bytes per sector, N
0547           OR      A
0548           JR      Z,$0552	; ---> ---> ---> ---> ---> ---> ---> --->|
054A           LD      A,L	;					 |
054B           DEC     A	;					 |
054C           SRL     A	;					 |
054E           SRL     A	;					 |
0550           INC     A	;					 |
0551           LD      L,A	; L = (L-1)/4 + 1			 |
0552           LD      A,($F021) ; <--- <--- <--- <--- <--- <--- <--- <--|
0555           ADD     A,C
0556           LD      D,A	; track
0557           LD      E,L
0558           RET
				; ############### READ_TABLE ###################
				; --- input: IX = table base
				; --- input: DE = displacement
				; --- output: A = byte read
0559           PUSH    IX
055B           ADD     IX,DE
055D           LD      A,(IX+$00)
0560           POP     IX
0562           RET
				; ############### PARAM_SET ####################
				; *** prepare parameters for next 8272 command (Read Data)
				; --- input: (F020) = 00 if prev.Read ID in FM successfull, nonzero if not (ST0 AND C0h)
0563           XOR     A
0564           LD      ($F01D),A; (F01D)=00
0567           LD      A,($F020); 00 if Read ID in FM successfull, nonzero if not (ST0 AND C0h)
056A           OR      A
056B           JR      Z,$058C	; if (F020)=00 ---> ---> ---> ->|
056D           LD      A,$46	;				|
056F           LD      ($F00C),A; (F00C)=46 (Read Data MFM)	|
0572           LD      A,$0A	;				|
0574           LD      ($F012),A; (F012)=0A (EOT)		|
0577           LD      A,$28	;				|
0579           LD      ($F01C),A; (F01C)=28			|
057C           LD      IX,$03A4	; MFM XLT table base		|						---@@@057F:03->0B
0580           LD      HL,$0002	;				|
0583           LD      ($F00A),HL ; (F00A)=02 (CTC2 TC), (F00B)=00 (CTC1 TC) -> 2x256=512B/sect
0586           LD      A,$02	;				|
0588           LD      ($F011),A; (F011)=02 (N)			|
058B           RET		;				|
				;				|
058C           LD      A,$06	; <--- <--- <--- <--- <--- <----|
058E           LD      ($F00C),A; (F00C)=06 (Read Data FM)
0591           LD      A,$1A
0593           LD      ($F012),A; (F012)=1A (EOT)
0596           LD      ($F01C),A; (F01C)=1A
0599           LD      IX,$038A	; FM XLT table base								---@@@059C:03->0B
059D           LD      HL,$8001
05A0           LD      ($F00A),HL ; (F00A)=01 (CTC2 TC), (F00B)=80 (CTC1 TC) -> 1x128=128B/sect
05A3           XOR     A
05A4           LD      ($F011),A; (F011)=00 (N)
05A7           RET
				; ############### RECALIBRATE ##################
				; *** must be used with int. vector CTC-0_INT_1
				; --- input: (F00D) = drive number
				; --- output: (F015) = Seek result byte 1 of 2 (ST0)
				; --- output: (F016) = Seek result byte 2 of 2 (PCN)
05A8           CALL    $05D2	; call FDD_READY								---@@@05AA:05->0D
05AB           LD      A,$07	; 8272 Recalibrate command - byte 1 of 2
05AD           OUT     ($FD),A	; send to 8272
05AF           CALL    $061A	; call 8272_READY								---@@@05B1:06->0E
05B2           LD      A,($F00D); 8272 Recalibrate command - byte 2 of 2 (drive number)
05B5           OUT     ($FD),A	; send to 8272
05B7           HALT		; wait for interrupt (int. vector must be CTC-0_INT_1)
05B8           RET
				; ############### SEEK #########################
				; *** must be used with int. vector CTC-0_INT_1
				; --- input: (F00D) = drive number
				; --- input: (F00E) = track number
				; --- output: (F015) = Seek result byte 1 of 2 (ST0)
				; --- output: (F016) = Seek result byte 2 of 2 (PCN)
05B9           CALL    $05D2	; call FDD_READY								---@@@05BB:05->0D
05BC           LD      A,$0F	; 8272 Seek command - byte 1 of 3
05BE           OUT     ($FD),A	; send to 8272
05C0           CALL    $061A	; call 8272_READY								---@@@05C2:06->0E
05C3           LD      A,($F00D); 8272 Seek command - byte 2 of 3 (drive number)
05C6           OUT     ($FD),A	; send to 8272
05C8           CALL    $061A	; call 8272_READY								---@@@05CA:06->0E
05CB           LD      A,($F00E); 8272 Seek command - byte 3 of 3 (cyl number to go to)
05CE           OUT     ($FD),A	; send to 8272
05D0           HALT		; wait for interrupt (int. vector must be CTC-0_INT_1)
05D1           RET
				; ############### FDD_READY ####################
05D2           CALL    $05E9	; call SENSE_DRIVE_STATUS							---@@@05D4:05->0D
05D5           AND     $20	; test bit 5 of status (result) byte (FDD Ready)
05D7           JR      NZ,$05DC	; if ready skip next line
05D9           JP      $0000	; restart this BOOT code							---@@@05DB:00->08
05DC           CALL    $0620	; call CTC_INIT									---@@@05DE:06->0E
05DF           LD      HL,$069C	; 										---@@@05E1:06->0E
05E2           LD      ($F000),HL ; CTC-0 int. vector to 069C (CTC-0_INT_1)
05E5           CALL    $0614	; call FDD+8272_READY								---@@@05E7:06->0E
05E8           RET
				; ############### SENSE_DRIVE_STATUS ###########
				; --- input: (F00D) = drive number, head
				; --- output: A = Sense Drive Status result (ST3)
05E9           CALL    $0614	; call FDD+8272_READY								---@@@05EB:06->0E
05EC           LD      A,$04	; Sense Drive Status command - byte 1 of 2
05EE           OUT     ($FD),A	; send to 8272
05F0           CALL    $061A	; call 8272 READY								---@@@05F2:06->0E
05F3           LD      A,($F00D); Sense Drive Status command - byte 2 of 2 (00, drive 0 Head 0)
05F6           OUT     ($FD),A	; send to 8272
05F8           CALL    $061A	; call 8272 READY								---@@@05FA:06->0E
05FB           IN      A,($FD)	; read 8272 data (status info)
05FD           RET
				; ############### FDD_SPECIFY ##################
05FE           CALL    $0614	; call FDD+8272_READY								---@@@0600:06->0E
0601           LD      A,$03	; Specify Command - byte 1 of 3
0603           OUT     ($FD),A	; send to 8272
0605           CALL    $061A	; call 8272 READY								---@@@0607:06->0E
0608           LD      A,$3F	; Specify Command - byte 2 of 3 (SRT=13 ms, HUT=240 ms)
060A           OUT     ($FD),A	; send to 8272
060C           CALL    $061A	; call 8272 READY								---@@@060E:06->0E
060F           LD      A,$17	; Specify Command - byte 3 of 3 (HLT=30 ms, Non-DMA mode)
0611           OUT     ($FD),A	; send to 8272
0613           RET
				; ############### FDD+8272_READY ###############
0614           IN      A,($F5)	; Read 8272 Status Register
0616           AND     $1F	; test bits 0 1 2 3 4 (drives in Seek Mode or Read/Write Command in progress)
0618           JR      NZ,$0614	; if Seek or Read/Write in progress go back 2 lines
061A           IN      A,($F5)	; Read 8272 Status Reg ###### 8272_READY #######
061C           RLCA		; test bit 7 (RQM - if Data register ready to send/receive)
061D           JR      NC,$061A	; if not ready, go back 2 lines
061F           RET
				; ############### CTC_INIT #################
				; --- input: (F00A) = CTC-2 Time Constant
				; --- input: (F00B) = CTC-1 Time Constant
0620           DI
0621           IM      2
0623           LD      HL,$F000	; interrupt vector table base
0626           LD      A,H
0627           LD      I,A	; I=F0 upper half of int. vector
0629           LD      A,L	; A=00
062A           OUT     ($E3),A	; CTC Channel 0, specify int. vector = 00000cc0
				; Interrupt service routine addresses are located at:
				; CTC-0 -> F000, CTC-1 -> F002, CTC-2 -> F004, CTC-3 -> F006
062C           LD      A,$DF	; 
062E           OUT     ($E3),A	; CTC-0 Enable Int. Counter Mode, Rising Edge, Time Constant Follows
0630           LD      A,$01	; Time Constant 1
0632           OUT     ($E3),A	; CTC-0 set to count to 1
0634           LD      HL,($F00A)
0637           LD      A,$5F	; 
0639           OUT     ($EB),A	; CTC-1 Disable Int, Counter Mode, Rising Edge, Time Constant Follows
063B           LD      A,H	; Time Constant from (F00B)
063C           OUT     ($EB),A	; send to CTC-1
063E           LD      A,$5F	;
0640           OUT     ($F3),A	; CTC-2 Disable Int, Counter Mode, Rising Edge, Time Constant Follows
0642           LD      A,L	; Time Constant from (F00A)
0643           OUT     ($F3),A	; send to CTC-2
0645           EI
0646           RET
				; ############# 8272_CMD #############
				; --- input: HL = CTC-0 int. vector (must be CTC-0_INT_2)
				; --- input: C = nr. of 8272 opcodes - 1
				; --- input: (F00C) = first 8272 opcode
				; --- input: (F008) = storage start addr for bytes read from 8272
				; --- output: (F01E-F01F) = current storage addr for next byte read from disk after this command
				; --- output: (F015-F01B) = 8272 command result (status) bytes
				; --- output: A = 00 if command terminated ok, nonzero if terminated abnormally
				; --- output: Z flag = 1 if command terminated ok, 0 if terminated abnormally
0647           LD      ($F000),HL ; CTC-0 int. service routine addr
064A           CALL    $0620	; CTC INIT									---@@@064C:06->0E
064D           LD      HL,($F008) ; storage start addr for bytes read from 8272
0650           LD      DE,$F00C	; addr of first 8272 opcode
0653           CALL    $0614	; CALL FDD+8272_READY								---@@@0655:06->0E
0656           CALL    $061A	; CALL 8272_READY <--- <--- <--- <--- <-|					---@@@0658:06->0E
0659           LD      A,(DE)	;					|
065A           OUT     ($FD),A	; send opcode to 8272			|
065C           INC     DE	; points to next opcode			|
065D           DEC     C	; opcode counter			|
065E           JR      NZ,$0656	; if not zero ---> ---> ---> ---> ----->|
0660           CALL    $061A	; call 8272_READY								---@@@0662:06->0E
0663           LD      A,(DE)	; last 8272 opcode
0664           LD      B,$20	; filter for bit 5 of status info of 8272 command
0666           LD      C,$FD	; port address for INI instruction in CTC-0_INT_2
0668           OUT     ($FD),A	; send last opcode to 8272
066A           HALT		; wait for first interrupt from Z80-CTC (signaling non-DMA byte transfer (Exec Phase) or begin of Result Phase)
066B           IN      A,($F5)	; read 8272 Status Register <--- <--- <--- <----|
066D           AND     B	; filter bit 5 of status info (B=20)		| (the Non-DMA bit)
066E           JP      NZ,$066B	; if bytes still transferring from FDD ---> --->| jump if still in Exec Phase	---@@@0670:06->0E
0671           LD      B,$00
0673           DJNZ    $0673	; repeat this DJNZ 256 times (256 x 13T = 0.9ms) ***during this the int. at begin of Result Phase occurs***
0675           DEC     HL	; HL points to first status byte read from 8272 (HL=F007 if CTC-0_INT_1)
0676           LD      ($F01E),HL ; (F01E-F01F)=addr of first status byte from 8272 (F007 if CTC-0_INT_1)
0679           LD      A,(HL)	; A=the first status byte read from 8272 (A=(F007) if CTC-0_INT_1)
067A           LD      HL,$F015
067D           LD      (HL),A	; (F015)=the first status byte read from 8272 (or =(F007) if CTC-0_INT_1)
067E           INC     HL	; HL=F016
067F           CALL    $061A	; call 8272_READY <--- <--- <---|						---@@@0681:06->0E
0682           IN      A,($FD)	; read 8272 status data		|
0684           LD      (HL),A	; (F016)=8272 status byte	| the status bytes from 8272
0685           INC     HL	; HL=F017			| are saved from F015 up (if CTC-0_INT_2)
0686           LD      B,$00	;				| and (F015)=first status byte
0688           DJNZ    $0688	; repeat this DJNZ 256 times    |
068A           IN      A,($F5)	; read 8272 Status Register	|
068C           AND     $10	; test bit 4 (FDC Busy)		|
068E           JR      NZ,$067F	; ---> ---> ---> ---> ---> ---->|
0690           LD      HL,$069C	;										---@@@0692:06->0E
0693           LD      ($F000),HL ; change to CTC-0_INT_1 (for non-Result-Phase commands)
0696           LD      A,($F015); the first status byte read from 8272
0699           AND     $C0	; test bits 6,7 (Normal Termination of Command, s/b 0)
069B           RET
				; ############# CTC-0_INT_1 ##############
				; *** for SEEK and RECALIBRATE commands (that don't have a Result phase)
				; --- output: (F015) = result byte 1 (ST0)
				; --- output: (F016) = result byte 2 (PCN)
069C           PUSH    AF
069D           PUSH    HL
069E           LD      HL,$F015
06A1           CALL    $061A	; call 8272 READY								---@@@06A3:06->0E
06A4           LD      A,$08	; 8272 opcode (Sense Int. Status)...
06A6           OUT     ($FD),A	; ...sent to 8272
06A8           CALL    $061A	; call 8272 READY								---@@@06AA:06->0E
06AB           IN      A,($FD)	; result byte 1 of 2...
06AD           LD      (HL),A	; ...stored at (F015) (ST0)
06AE           INC     HL
06AF           CALL    $061A	; call 8272 READY								---@@@06B1:06->0E
06B2           IN      A,($FD)	; result byte 2 of 2...
06B4           LD      (HL),A	; ...stored at (F016) (PCN)
06B5           POP     HL
06B6           POP     AF
06B7           EI
06B8           RETI
				; ############# CTC-0_INT_2 ##############
				; *** for commands other than SEEK and RECALIBRATE (that have a Result phase)
06BA           INI
06BC           INC     B	; B maintained at initial value (it is incremented during INI)
06BD           EI
06BE           RETI
				; ############### BASIC LOADING #################
06C0           LD      BC,$2000	; load BASIC,
06C3           LD      DE,$8000	;
06C6           LD      HL,$4000	;
06C9           LDIR    		;  half at 8000-9FFF
06CB           LD      BC,$2000	;
06CE           LD      DE,$E000	;
06D1           LD      HL,$6000	;
06D4           LDIR		;  and half at E000-FFFF
06D6           LD      HL,$0000	; jump addr in BASIC config
06D9           XOR     A
06DA           OUT     ($FE),A	; border black, "O5"="O6"=0
06DC           LD      R,A	; reset bit 7 of R
06DE           JP      (HL)	; jump to BASIC start
				; ############## END BASIC LOADING ##############
06DF           LD      SP,$C000
06E2           SCF
06E3           LD      IX,$8000
06E7           LD      DE,$2000
06EA           LD      A,$FE
06EC           CALL    $073A	;										---@@@06EE:07->0F
06EF           JP      NC,$0000
06F2           LD      IX,$E000
06F6           LD      DE,$2000
06F9           SCF
06FA           LD      A,$FE
06FC           CALL    $073A	;										---@@@06FE:07->0F
06FF           JP      NC,$0000	;										---@@@0701:00->08
0702           JP      $06D6	;										---@@@0704:06->0E
0705           RRA		; test column K0 ("SPACE" "Q" "A" "CS")
0706           JP      C,$0710	; if key pressed skip next 3 lines ---> --->|					---@@@0708:07->0F
0709           LD      A,$02	;					    |
070B           OUT     (C),A	; write "02" to port C 8255 (border red) <------|
070D           JP      $06C0	; jump to BASIC LOADING			    |	|				---@@@070F:06->0E
0710           RRA		; test column K1 ("SS" "W" "S" "Z") <--- <--|	|
0711           JP      C,$00B7	; if key pressed, go back to beginning		|				---@@@0713:00->08
0714           LD      A,$05	; if not, A=05 (border=cyan)			|
0716           JP      $070B	; ---> ---> ---> ---> ---> ---> ---> ---> ----->|				---@@@0718:07->0F
0719           LD      A,$04	; border green
071B           OUT     (C),A
071D           JP      $06C0	; jump to BASIC LOADING								---@@@071F:06->0E
0720           RLCA
0721           JP      C,$06C0	;										---@@@0723:06->0E
0724           PUSH    IX
0726           POP     AF
0727           AND     3F
0729           SRL     A
072B           SRL     A
072D           SRL     A
072F           LD      E,A
0730           LD      D,$00
0732           LD      HL,$DA8C
0735           ADD     HL,DE
0736           SET     7,(HL)
0738           JR      $0738
				; #########
073A           INC     D
073B           EX      AF,AF'
073C           DEC     D
073D           DI
073E           LD      A,$0F
0740           OUT     ($FE),A	; border=white, Tape Out=1
0742           IN      A,($FE)	; read keyboard + Tape In
0744           RRA
0745           AND     $20	; test bit 5 (Tape In shifted)
0747           OR      $02	; set bit 1
0749           LD      C,A
074A           CP      A
074B           RET     NZ

074C           CALL    $07C7	;										---@@@074E:07->0F
074F           JR      NC,$074B
0751           LD      HL,$0415
0754           DJNZ    $0754
0756           DEC     HL
0757           LD      A,H
0758           OR      L
0759           JR      NZ,$0754
075B           CALL    $07C3	;										---@@@075D:07->0F
075E           JR      NC,$074B
0760           LD      B,$9C
0762           CALL    $07C3	;										---@@@0764:07->0F
0765           JR      NC,$074B
0767           LD      A,$C6
0769           CP      B
076A           JR      NC,$074C
076C           INC     H
076D           JR      NZ,$0760
076F           LD      B,$C9
0771           CALL    $07C7	;										---@@@0773:07->0F
0774           JR      NC,$074B
0776           LD      A,B
0777           CP      $D4
0779           JR      NC,$076F
077B           CALL    $07C7	;										---@@@077D:07->0F
077E           RET     NC

077F           LD      A,C
0780           XOR     $03
0782           LD      C,A
0783           LD      H,$00
0785           LD      B,$B0
0787           JR      $07A8
0789           EX      AF,AF'
078A           JR      NZ,$0793
078C           JR      NC,$079D
078E           LD      (IX+$00),L
0791           JR      $07A2
0793           RL      C
0795           XOR     L
0796           RET     NZ

0797           LD      A,C
0798           RRA
0799           LD      C,A
079A           INC     DE
079B           JR      $07A4
079D           LD      A,(IX+$00)
07A0           XOR     L
07A1           RET     NZ

07A2           INC     IX
07A4           DEC     DE
07A5           EX      AF,AF'
07A6           LD      B,$B2
07A8           LD      L,$01
07AA           CALL    $07C3	;										---@@@07AC:07->0F
07AD           RET     NC

07AE           LD      A,$CB
07B0           CP      B
07B1           RL      L
07B3           LD      B,$B0
07B5           JP      NC,$07AA	;										---@@@07B7:07->0F
07B8           LD      A,H
07B9           XOR     L
07BA           LD      H,A
07BB           LD      A,D
07BC           OR      E
07BD           JR      NZ,$0789
07BF           LD      A,H
07C0           CP      01
07C2           RET

07C3           CALL    $07C7	;										---@@@07C5:07->0F
07C6           RET     NC	; return if SPACE pressed
				; ########### DELAY + TAPE IN TEST ###########
07C7           LD      A,$16	; for
07C9           DEC     A	; delay
07CA           JR      NZ,$07C9	; purposes
07CC           AND     A	; CY flag reset
07CD           INC     B	; <--- <--- <--- <--- <--- <----|
07CE           RET     Z	; return if B=00		|
				;				|
07CF           LD      A,$7F	; test keyboard row KA15	|
07D1           IN      A,($FE)	; read keyboard			|
07D3           RRA		; test column K0 ("SPACE" key)	|
07D4           RET     NC	; return if pressed		|
				;				|
07D5           XOR     C	; A xor C			|
07D6           AND     $20	; test bit 5 of A (Tape Input)	|
07D8           JR      Z,$07CD	; if zero ---> ---> ---> ---> -->
07DA           LD      A,C
07DB           CPL
07DC           LD      C,A	; invert C
07DD           AND     $07	; filter bits 0, 1, 2
07DF           OR      $08	; set bit 3
07E1           OUT     ($FE),A
07E3           SCF		; CY=1
07E4           RET

07E5           JR      NC,07CB
07E7           LD      A,C6
07E9           CP      B
07EA           JR      NC,07CC
07EC           INC     H
07ED           JR      NZ,07E0
07EF           LD      B,C9
07F1           CALL    07C7	;										---@@@07F3:07->0F
07F4           JR      NC,07CB
07F6           LD      A,B
07F7           CP      D4
07F9           JR      NC,07EF
07FB           CALL    07C7	;										---@@@07FD:07->0F
07FE           RET     NC

07FF           LD      A,C
